package com.qxzn.app.medicalhealth.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.qxzn.app.medicalhealth.R;

/**
 * Created by ZWH on 2016/5/16.
 */
public class GalleryAdapter extends BaseAdapter {
    private Context mContext;
    //设置要展示的图片资源
    int[] images = {R.mipmap.logo, R.mipmap.logo, R.mipmap.logo, R.mipmap.logo};

    public GalleryAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return images.length;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        //在此最好判断一下view是否为空
//        ImageView image = new ImageView(mContext);
//        image.setImageResource(images[i]);
//        image.setAdjustViewBounds(true);
//        //设置宽高
//        image.setLayoutParams(new Gallery.LayoutParams(
//                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        View view1 = LayoutInflater.from(mContext).inflate(R.layout.item_medical_health, viewGroup, false);
        return view1;
    }
}